export default {
  data() {
    let handlerPhone = (rule, value, callback) => {
      if (!this.regCheck('empty', value)) {
        callback(new Error('请输入联系电话'))
      } else if (this.regCheck('phone', value)) {
        callback(new Error('请输入正确的联系电话'))
      } else {
        callback()
      }
    }
    let handlerCertificatesNumber = (rule, value, callback) => {
      if (!this.regCheck('empty', value)) {
        callback(new Error('请输入证件号码'))
      } else {
        callback()
      }
    }
    return {
      ruleForm: {
        handlerName: '', //经办人姓名
        handlerCertificatesType: '', //证件类型
        handlerCertificatesNumber: '', //证件号码
        handlerSex: '', //经办人性别
        handlerPhone: '', //手机号
        Verification_Code: '', //验证码
        SMS_verification_Code: '', //短信验证码
        companyName: '', //企业名称
        companyCode: '', //统一社会信用代码
        companyPerson: '', //法定代表人或负责人姓名
        companyCertificatesType: '', //证件类型
        companyCertificatesNumber: '', //证件号码
        companyCertificateFile: '', //	上传证明文件文件批次id
        companyCertificatesFile: '', //上传身份证件(正面)id
        companyCertificatesBackFile: '', //上传身份证件(背面)id
      },
      rules: {
        handlerName: [
          { required: true, message: '请输入经办人姓名', trigger: 'blur' },
        ],
        handlerCertificatesType: [
          { required: true, message: '请选择经办人证件类型', trigger: 'change' },
        ],
        handlerCertificatesNumber: [
          { required: true, validator: handlerCertificatesNumber, trigger: 'blur' },
        ],
        handlerSex: [
          { required: true, message: '请选择经办人性别', trigger: 'change' },
        ],
        handlerPhone: [
          { required: true, validator: handlerPhone, trigger: 'blur' },
        ],
        Verification_Code: [
          { required: true, message: '请输入验证码', trigger: 'blur' },
          { trigger: 'blur', validator: (rule, value, callback) => {
              if(value != this.realCode) {
                callback(new Error('验证码错误'))
              } else {
                callback()
              }
            }
          }
        ],
        SMS_verification_Code: [
          { required: true, message: '请输入短信验证码', trigger: 'blur' },
        ],
        companyName: [
          { required: true, message: '请输入企业名称', trigger: 'blur' },
        ],
        companyCode: [
          { required: true, message: '请输入统一社会信用代码', trigger: 'blur' },
        ],
        companyPerson: [
          { required: true, message: '请输入法定代表人或负责人姓名', trigger: 'blur' },
        ],
        companyCertificatesType: [
          { required: true, message: '请选择经办人证件类型', trigger: 'change' },
        ],
        companyCertificatesNumber: [
          { required: true, validator: handlerCertificatesNumber, trigger: 'blur' },
        ],
        companyCertificateFile: [
          { required: true, message: '请上传证明文件文件', trigger: 'change' },
        ],
        companyCertificatesFile: [
          { required: true, message: '请上传身份证件(正面)', trigger: 'change' },
        ],
        companyCertificatesBackFile: [
          { required: true, message: '请上传身份证件(背面)', trigger: 'change' },
        ],
      },
    }
  }
}
